# -*-coding:utf-8-*-

import tensorflow as tf

default_graph = tf.Graph()

with default_graph.as_default():
    # 设置变量value=0
    value = tf.get_variable("value", initializer=tf.zeros_initializer, shape=[1])

g2 = tf.Graph()
with g2.as_default():
    value = tf.get_variable("value", initializer=tf.ones_initializer, shape=[1])

with tf.Session(graph=default_graph) as sess:
    # 此处注意：tf.initialize_all_variables.run()已经被废弃，现在使用tf.global_variables_initializer().run()代替
    tf.global_variables_initializer().run()
    with tf.variable_scope("", reuse=True):
        print(sess.run(tf.get_local_variable("value")))

with tf.Session(graph=g2) as sess:
    tf.global_variables_initializer().run()
    with tf.variable_scope("", reuse=True):
        print(sess.run(tf.get_local_variable("value")))

